/*
2021-11-8
https://ac.nowcoder.com/acm/contest/22551/I
*/
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;
typedef pair<int, int>PII;
const int N = 1005;
char g[N][N];
int n, m;
int sx1, sy1, sx2, sy2;
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };
int dist[N][N];

int bfs1()
{
    queue<PII>q;
    q.push({ sx1,sy1 });
    dist[sx1][sy1] = 0;
    while (q.size())
    {
        auto t = q.front();
        q.pop();
        int x = t.first, y = t.second;
        for (int i = 0; i < 4; i++)
        {
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || a >= n || b < 0 || b >= m) continue;
            if (dist[a][b] != 0x3f3f3f3f) continue;
            if (g[a][b] == '$' || g[a][b] == '&') continue;
            dist[a][b] = dist[x][y] + 1;
            q.push({ a,b });
        }
    }
    return dist[sx2][sy2];
}

int bfs2()
{
    queue<PII>q;
    q.push({ sx2,sy2 });
    dist[sx2][sy2] = 0;
    while (q.size())
    {
        auto t = q.front();
        q.pop();
        int x = t.first, y = t.second;
        if (x == 0 || x == n - 1 || y == 0 || y == m - 1) return dist[x][y];
        for (int i = 0; i < 4; i++)
        {
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || a >= n || b < 0 || b >= m) continue;
            if (dist[a][b] != 0x3f3f3f3f) continue;
            if (g[a][b] == '$' || g[a][b] == '&') continue;
            dist[a][b] = dist[x][y] + 1;
            q.push({ a,b });
            if (a == 0 || a == n - 1 || b == 0 || b == m - 1) return dist[a][b];
        }
    }
    return 0x3f3f3f3f;
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> g[i];
        for (int j = 0; j < m; j++)
        {
            if (g[i][j] == 'D') sx1 = i, sy1 = j;
            if (g[i][j] == 'P') sx2 = i, sy2 = j;
        }
    }
    memset(dist, 0x3f, sizeof dist);
    int a1 = bfs1();
    if (a1 == 0x3f3f3f3f)
    {
        cout << "What is life without you" << endl;
        return 0;
    }
    else
    {
        memset(dist, 0x3f, sizeof dist);
        int a2 = bfs2();
        if (a2 == 0x3f3f3f3f)
        {
            cout << "What is life without you" << endl;
            return 0;
        }
        cout << "You woke up at " << a1 + a2 + 1 << " seconds" << endl;
    }
    return 0;
}